<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set var="jpath" value="${pageContext.request.contextPath }"/>
<!DOCTYPE html >
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0,minimum-scale=1.0,user-scalable=0" />
<script type="text/javascript" src="${jpath}/static/FrontStatic/js/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="${jpath}/static/FrontStatic/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="${jpath}/static/FrontStatic/css/bootstrap.min.css"/>
<link rel="stylesheet" type="text/css" href="${jpath}/static/FrontStatic/css/cpsc.css"/>


<title>无标题文档</title>
</head>

<body>
	<div class="bj">
        <div class="container">
           <div class="row title">
              <div class="col-2">
                <img id="back" src="${jpath}/static/FrontStatic/image/back.png" />
              </div>
              <div class="col-8">产品上传</div>  
              <div class="col-2"></div>     
           </div>
        </div>
        <div class="content">
        	<form id="usForm">
            	<div class="container">
                   <div class="row contitle">
                      <div class="col-12"><span class="contitle_color">|</span>产品介绍</div>   
                   </div>
                </div>
                <div class="contentOne">
                	<div class="container">
                       <div class="row contentOne_row">
                          <div class="col-4 contitle_color">产品名称：</div>
                          <div class="col-8">
                          	<input class="input" type="text" name="Productame" id="Productame"  placeholder="请输入产品名称"/>
                          </div>     
                       </div>
                    </div>
                    <div class="container">
                       <div class="row contentOne_row">
                          <div class="col-4 contitle_color">产品金额：</div>
                          <div class="col-8">
                          	<input class="input" name="Money" id="Money"   type="text"  placeholder="请输入产品金额"/>
                          </div>     
                       </div>
                    </div>
                    <div class="container">
                       <div class="row contentOne_row">
                          <div class="col-4 contitle_color">办理条件：</div>
                          <div class="col-8">
                          	<textarea class="input" name="Conditions" id="Conditions" rows="3" style="resize:none;" placeholder="请输入办理条件"></textarea>
                          </div>     
                       </div>
                    </div>
                    <div class="container">
                       <div class="row contentOne_row">
                          <div class="col-4 contitle_color">办理流程：</div>
                          <div class="col-8">
                          	<textarea class="input" name="Process" id="Process" rows="3" style="resize:none;" placeholder="请输入办理流程"></textarea>
                          </div>     
                       </div>
                    </div>
                    <div class="container">
                       <div class="row contentOne_row">
                          <div class="col-4 contitle_color">办理简介：</div>
                          <div class="col-8">
                          	<textarea class="input" name="Introduction" id="Introduction" rows="3" style="resize:none;" placeholder="请输入办理简介"></textarea>
                          </div>     
                       </div>
                    </div>
                </div>
                <div class="container">
                   <div class="row contitle">    
                      <div class="col-12"><span class="contitle_color">|</span>关于我们</div> 
                   </div>
                </div>
                <div class="contentOne">
                	<div class="container">
                       <div class="row contentOne_row">
                          <div class="col-4 contitle_color">公司规模：</div>
                          <div class="col-8">
                          	<input class="input" name="Scale" id="Scale"  type="text"  placeholder="请输入公司规模"/>
                          </div>     
                       </div>
                    </div>
                    <div class="container">
                       <div class="row contentOne_row">
                          <div class="col-4 contitle_color">融资时限：</div>
                          <div class="col-8">
                          	<input class="input" name="TimLimit" id="TimLimit" type="text"  placeholder="融资时限"/>
                          </div>     
                       </div>
                    </div>
                    <div class="container">
                       <div class="row contentOne_row">
                          <div class="col-4 contitle_color">联系部门：</div>
                          <div class="col-8">
                          	<input class="input"  name="Department" id="Department"  type="text"  placeholder="请输入联系部门"/>
                          </div>     
                       </div>
                    </div>
                    <div class="container">
                       <div class="row contentOne_row">
                          <div class="col-4 contitle_color">联系电话：</div>
                          <div class="col-8">
                          	<input class="input" name="ContactUs" id="ContactUs"  type="text"  placeholder="请输入联系电话"/>
                          </div>     
                       </div>
                    </div>
                </div>
                <div class="container">
                   <div class="row contitle">
                      <div class="col-12"><span class="contitle_color">|</span>图片上传</div> 
                   </div>
                </div>
                <div class="contentOne">
                	<div class="container">
                       <div class="row contentOne_row">
                          <div class="col-4 contitle_color">上传图片：</div>
                          <div class="col-8">
                          	<div class="upload">
                             	<div class="upload_div" id="file">
                                  	<img class="upload_img" src="${jpath}/static/FrontStatic/image/add_photo.png" />
                      	  			<input id="file_btn" accept="image/*" style="display:none" type="file"  />
                      	  			<input type="hidden" id="AssociatedId" name="AssociatedId" value="">
                            	</div>
                                <br style=" clear:both;"/>
                          	</div>
                          </div>     
                       </div>
                    </div>
                </div>
                <div class="container">
                   <div class="row end">
                      <div class="col-6">
                      	<span class="but" style="background-color:#2864a7">保存预览</span>
                      </div>
                      <div class="col-6" >
                      	<span class="but" id="sub-btn" style="background-color:#f86941">发布</span>
                      </div>
                   </div>
                </div>
            </form>
        </div>
    </div>
    
<script src="${jpath}/js/system_plugins.js"></script>
<script>
	var jpath="${jpath}";
	function del(_this) {
		var _this_img = $(_this);
		_this_img.parent().remove();
	}
	
	$(function() {
		$("#back").click(function(){
			location.href="${jpath}/front/index";
		});
		var file = $("#file_btn");
		$("#file").click(function(){
			file[0].click();
		});
		file[0].addEventListener('change', function() {
			var file = this.files[0];
			var reader = new FileReader();
			reader.readAsDataURL(file);
			reader.onload = function(e){
				var newUrl = this.result;
				var img_str = '<div class="mainPic">';
				img_str += '<img width="50px" id="base64Img" src="' + newUrl + '" />';
				img_str += '<img onclick="del(this)" class="del_btn" src="'+jpath+'/static/FrontStatic/image/close.png" />';
				img_str += '</div>';
				$("#file").after(img_str);
			};
		});
		$("#sub-btn").click(function(){
			var src=$("#base64Img").attr("src");
			console.log("src:"+src);
			var file=$("#file_btn").get(0).files[0];
			//var FirstFileName=file.name;
			$.post("${jpath}/uploadFile",{base64File:src,FirstFileName:file.name},function(data){
					console.log(data);
					var json=$.parseJSON(data);
					$("#attId").val(json.attId);
					if(json.attId!=null){
						var jsonForms=$("#usForm").getForm();
						$.post("${jpath}/FrontProduct/AddProduct",jsonForms,function(data){
								console.log(data);
								var json=$.parseJSON(data);
								alert(json.resMsg);
							}
						);
					}
				}
			);
		});
	});
	
</script>
</body>
</html>
 